package com.feiyi.app.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.blankj.utilcode.util.SPUtils;
import com.feiyi.app.app.AppApplication;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

/**
 * 作者 : wlt
 * 创建时间:  2018-07-12
 * QQ : 1346947404
 * 邮箱:wanglt_android@163.com
 * 类说明:
 * In me the tiger sniffs the rose
 */

public class BaseActivity extends AppCompatActivity {

    public BaseActivity activity;
    public AppApplication application;
    private CompositeDisposable compositeDisposable;
    public static SPUtils spUtils;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity = this;
        application = AppApplication.getApp();
        spUtils = SPUtils.getInstance();
    }
    /**
     * @param disposable 添加事件队列
     */
    public void addDisposable(Disposable disposable) {
        if (compositeDisposable == null) {
            compositeDisposable = new CompositeDisposable();
        }
        compositeDisposable.add(disposable);
    }

    /**
     * 销毁事件队列
     */
    public void dispose() {
        if (compositeDisposable != null) compositeDisposable.dispose();
    }

    /**
     * 销毁
     */
    @Override
    public void onDestroy() {
        super.onDestroy();
        dispose();
    }
}
